import java.util.Arrays;

public class TextDemo {
    public static void BubbleSort(int[] array) {
    int lastIndex = array.length-1;
    int swapIndex = 0;
    boolean flag = true;
    while(flag){
        flag = false;
        for(int i = 0;i<lastIndex ;i++){
            if(array[i]>array[i+1]){
                swap(array,i,i+1);
                flag = true;
                swapIndex = i;
            }
        }
        lastIndex = swapIndex;
    }

    }
    public static void selectionSort(int[] array){
        int maxIndex = 0;
        int minIndex = 0;
        for(int i = 0;i< array.length/2;i++){
            maxIndex = i;
            minIndex = i;
            for(int j = i+1;j< array.length-i;j++){
                if(array[minIndex]>array[j]){
                    minIndex = j;
                }
                if(array[maxIndex]<array[j]){
                    maxIndex = j;
                }
            }
            if(minIndex==maxIndex){
                return;
            }
            swap(array,minIndex,i);
            if(i==maxIndex){
                maxIndex = minIndex;
            }
            int lastIndex = array.length-1-i;
            swap(array,lastIndex,maxIndex);
        }
    }

    public static void insertSort(int[] array){
        for(int i = 1;i<array.length;i++){
            int j = i;
            while(j>=1&&array[j]<array[j-1]){
                swap(array,j-1,j);
                j--;
            }
        }

    }

    public static void insertSort1(int[] array){
       for(int i = 1;i<array.length;i++) {
           int j = i - 1;
           int currentNumber = array[i];
           while (j >= 0 && currentNumber < array[j]) {
               array[j + 1] = array[j];
               j--;
           }
           array[j + 1] = currentNumber;
       }
    }

      public static void shellSort(int[] array){
        for(int gap = array.length/2;gap>0;gap/=2){
            for(int gapStarIndex = )
        }
      }















    private static void swap(int[] array,int x,int y){
        int tem = array[x];
        array[x] = array[y];
        array[y] = tem;
    }

    public static void main(String[] args) {
        int[] array = new int[]{6,8,1,9,0,3,9,4,2,6,5,8,1,0,7};
        System.out.println(Arrays.toString(array));
        shellSort(array);
        System.out.println(Arrays.toString(array));
    }
}
